Connect to location-selected on the places sidebar, and actually switch folders\!
authorFederico Mena Quintero <federico@gnome.org>
Fri, 7 Sep 2012 19:35:56 +0000 (14:35 -0500)
committerFederico Mena Quintero <federico@gnome.org>
Fri, 7 Sep 2012 19:35:56 +0000 (14:35 -0500)
Signed-off-by: Federico Mena Quintero <federico@gnome.org>
gtk/gtkfilechooserdefault.c

index b355c689447c43878e2e0d7b30896495d20b8ba8..1eb6736dd5ed745e907bab65f7e25eb53d938b2e 100644 (file)
  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
+/* TODO:
+ *
+ * * Fix instances of "#if REMOVE_FOR_PLACES_SIDEBAR"
+ *
+ * * Fix FIXME-places-sidebar
+ */
+
 #include "config.h"
 
 #include "gtkfilechooserdefault.h"
@@ -3737,12 +3744,42 @@ shortcuts_pane_create (GtkFileChooserDefault *impl,
 }
 #endif
 
+static void
+places_sidebar_location_selected_cb (GtkPlacesSidebar *sidebar, GFile *location, GtkPlacesOpenMode open_mode, GtkFileChooserDefault *impl)
+{
+  gboolean clear_entry;
+
+  /* FIXME-places-sidebar: see shortcuts_activate_iter() for missing pieces.  In particular:
+   *
+   * * Search mode
+   *
+   * * Recent-files mode
+   */
+
+  /* In the Save modes, we want to preserve what the uesr typed in the filename
+   * entry, so that he may choose another folder without erasing his typed name.
+   */
+  if (impl->location_entry
+      && !(impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
+          || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
+    clear_entry = TRUE;
+  else
+    clear_entry = FALSE;
+
+  change_folder_and_display_error (impl, location, clear_entry);
+}
+
 /* Creates the widgets for the shortcuts/bookmarks pane */
 static GtkWidget *
 shortcuts_pane_create (GtkFileChooserDefault *impl,
                       GtkSizeGroup          *size_group)
 {
   impl->places_sidebar = gtk_places_sidebar_new ();
+
+  g_signal_connect (impl->places_sidebar, "location-selected",
+                   G_CALLBACK (places_sidebar_location_selected_cb),
+                   impl);
+
   return impl->places_sidebar;
 }